import Vue from 'vue';
import Router from 'vue-router';
const _import = require('./_import_' + process.env.NODE_ENV);
// in development env not use Lazy Loading,because Lazy Loading large page will cause webpack hot update too slow.so only in production use Lazy Loading

Vue.use(Router);

/* layout */
import Layout from '../views/layout/Layout';

/**
 * icon : the icon show in the sidebar
 * hidden : if `hidden:true` will not show in the sidebar
 * redirect : if `redirect:noredirect` will no redirct in the levelbar
 * noDropdown : if `noDropdown:true` will has no submenu
 * meta : { role: ['admin'] }  will control the page role
 **/
export const constantRouterMap = [{
    path: '/login',
    name: '登录',
    component: _import('login/index'),
    hidden: true
  },{
    path: '/authredirect',
    name:'',
    component: _import('login/authredirect'),
    hidden: true
  },{
    path: '/404',
    name:'404',
    component: _import('error/404'),
    hidden: true
  },{
    path: '/401',
    name:'401',
    component: _import('error/401'),
    hidden: true
  },{
    path: '/',
    component: Layout,
    redirect: '/welcome',
    name: '首页',
    hidden: true,
    children: [{
      path: 'dashboard',
      redirect: '/welcome',
      component: _import('dashboard/index'),
    }]
  },{
    path: '/',
    component: Layout,
    name: '',
    hidden: true,
    children: [{
      path: 'welcome',
      component: _import('welcome/index'),
    }]
  },{
    path: '/',
    component: Layout,
    name: '',
    hidden: true,
    children: [{
      path: 'shopAuditDetails',
      component: _import('z_auditManage/shopAudit/shopAuditDetails/index'),
      name: '店铺审核详情',
    }]
  },{
    path: '/',
    component: Layout,
    name: '',
    hidden: true,
    children: [{
      path: 'agentAuditDetails',
      component: _import('z_auditManage/components/agentAuditDetails'),
      name: '代理商审核详情',
    }]
  },{
    path: '/',
    component: Layout,
    name: '',
    hidden: true,
    children: [{
      path: 'firmAuditDetails',
      component: _import('z_auditManage/components/firmAuditDetails'),
      name: '公司审核详情',
    }]
  },{
    path: '/',
    component: Layout,
    name: '',
    hidden: true,
    children: [{
      path: 'merAuditDetails',
      component: _import('z_auditManage/components/merAuditDetails'),
      name: '商户审核详情',
    }]
  },{
    path: '/',
    component: Layout,
    name: '',
    hidden: true,
    children: [{
      path: 'handleAgent',
      component: _import('z_businessManagement/components/agentManage'),
      name: '操作代理商',
    }]
  },{
    path: '/',
    component: Layout,
    name: '',
    hidden: true,
    children: [{
      path: 'handleMer',
      component: _import('z_businessManagement/components/merDetails'),
      name: '操作商户',
    }]
  },{
    path: '/',
    component: Layout,
    name: '',
    hidden: true,
    children: [{
      path: 'handleShop',
      component: _import('z_businessManagement/components/shop'),
      name: '操作店铺',
    }]
  },{
    path: '/',
    component: Layout,
    name: '',
    hidden: true,
    children: [{
      path: 'handleFirm',
      component:  _import('z_businessManagement/components/firmDetails'),
      name: '操作公司',
    }]
  },
]

export default new Router({
  mode: 'history', //后端支持可开
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap
});

export const asyncRouterMap = [{
  path: '',
  component: Layout,
  name: '基础配置管理',
  authority: 'baseManager',
  children: [{
    path: 'user',
    component: _import('admin/user/index'),
    name: '用户管理',
    authority: 'userManager'
  }, {
    path: 'menu',
    component: _import('admin/menu/index'),
    name: '菜单管理',
    authority: 'menuManager'
  }, {
    path: 'group',
    component: _import('admin/group/index'),
    name: '角色权限管理',
    authority: 'groupManager'
  }, {
    path: 'group_type',
    component: _import('admin/groupType/index'),
    name: '角色类型管理',
    authority: 'groupTypeManager'
  }, {
    path: 'gate_log',
    component: _import('admin/gateLog/index'),
    name: '操作日志管理',
    authority: 'gateLogManager'
  }]
}, {
  path: '',
  component: Layout,
  name: '交易管理',
  authority: 'z_tradeManagement',
  children: [{
    path: 'trade',
    component: _import('z_tradeManagement/index'),
    name: '交易流水',
    authority: 'tradingFlow'
  }]
}, {
  path: '',
  component: Layout,
  name: '客户管理',
  authority: 'z_businessManagement',
  children: [{
    path: 'merchant',
    component: _import('z_businessManagement/index'),
    name: '商户',
    authority: 'merchant',
  }, {
    path: 'agent',
    component: _import('z_businessManagement/agent/index'),
    name: '代理商',
    authority: 'agent'
  },{
    path: 'firm',
    icon: 'cash-cny',
    component: _import('z_businessManagement/firm/index'),
    name: '公司',
    authority: 'firm'
  },{
    path: 'opinion',
    icon: 'cash-cny',
    component: _import('z_businessManagement/opinion/index'),
    name: '公司',
    authority: 'opinion'
  }]
}, {
  path: '',
  component: Layout,
  name: '审核管理',
  authority: 'z_auditManage',
  children: [{
    path: 'merAudit',
    component: _import('z_auditManage/merAudit/index'),
    name: '商户审核',
    authority: 'merAudit'
  }, {
    path: 'shopAudit',
    component: _import('z_auditManage/shopAudit/index'),
    name: '店铺审核',
    authority: 'shopAudit'
  }, {
    path: 'agentAudit',
    component: _import('z_auditManage/agentAudit/index'),
    name: '代理商审核',
    authority: 'agentAudit'
  },{
    path: 'withdrawAudit',
    icon: 'cash-cny',
    component: _import('z_merchantWithdrawCash/withdrawAudit'),
    name: '待审核兑现',
    authority: 'withdrawAudit',
  } ,{
    path: 'firmAudit',
    icon: 'cash-cny',
    component: _import('z_auditManage/firmAudit/index'),
    name: '公司审核',
    authority: 'firmAudit',
  } ]
}, {
  path: '',
  component: Layout,
  name: '机构管理',
  authority: 'z_mechanism',
  children: [{
    path: 'mechanism',
    component: _import('z_mechanism/mechanism/index'),
    name: '机构管理',
    authority: 'mechanism'
  }]
}, {
  path: '',
  icon: 'Device',
  component: Layout,
  name: '设备',
  authority: 'device',
  children: [{
    path: 'deviceManagement',
    icon: 'Device',
    component: _import('z_deviceManagement/index'),
    name: '设备管理',
    authority: 'deviceManagement'
  }, {
    path: 'solidCode',
    icon: 'Device',
    component: _import('z_solidCode/index'),
    name: '固码',
    authority: 'solidCode'
  }, ]
}, {
  path: '',
  icon: 'cash-cny',
  component: Layout,
  name: '兑现',
  authority: 'withdrawCash',
  children: [{
    path: 'merchantWithdrawCash',
    icon: 'cash-cny',
    component: _import('z_merchantWithdrawCash/index'),
    name: '兑现',
    authority: 'merchantWithdrawCash',
  },{
    path: 'profit',
    icon: 'cash-cny',
    component: _import('z_merchantWithdrawCash/profit/index'),
    name: '分润',
    authority: 'profit',
  },{
    path: 'fund',
    icon: 'cash-cny',
    component: _import('z_merchantWithdrawCash/fund/index'),
    name: '资金管理',
    authority: 'fund',
  },{
    path: 'settlement',
    icon: 'cash-cny',
    component: _import('z_merchantWithdrawCash/settlement/index'),
    name: '商户结算',
    authority: 'settlement',
  }]
}, {
  path: '',
  icon: 'cash-cny',
  component: Layout,
  name: '人员管理',
  authority: 'personnelManagement',
  children: [{
    path: 'salesmanManagement',
    icon: 'cash-cny',
    component: _import('z_SalesmanManage/index'),
    name: '业务员管理',
    authority: 'salesmanManagement'
  }]
},{
  path: '',
  icon: 'cash-cny',
  component: Layout,
  name: '广告',
  authority: 'ad_management',
  children: [{
    path: 'ad',
    icon: 'cash-cny',
    component: _import('z_advert/index'),
    name: '广告',
    authority: 'ad_ad'
  }]
},];
